//
//  TravelTourTwoTableViewCell.m
//  ToWhere
//
//  Created by dllo on 15/11/18.
//  Copyright © 2015年 www.TE.com. All rights reserved.
//

#import "TravelTourTwoTableViewCell.h"
#import "TravelTopicDetailsOneTableViewCell.h"

@interface TravelTourTwoTableViewCell ()

@property (nonatomic, retain) UILabel *labelDes;
@property (nonatomic, retain) UILabel *labelStart_date;
@property (nonatomic, retain) UILabel *labelUserName;


@end


@implementation TravelTourTwoTableViewCell

-(void)dealloc
{
    [_labelDes release];
    [_labelStart_date release];
    [_labelUserName release];
    [_model release];
    [_dic release];
    [super dealloc];
}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        [self createView];
    }
    
    return self;
    
}


-(void)createView
{
    self.labelDes = [[UILabel alloc]init];
    self.labelDes.font = [UIFont systemFontOfSize:14 *kWidth];
    
    self.labelDes.numberOfLines = 0;
    
    [self addSubview:self.labelDes];
    [_labelDes release];
    
    
    self.labelUserName = [[UILabel alloc]init];
    self.labelUserName.font = [UIFont systemFontOfSize: 12 *kWidth];
#pragma mark 改变字体颜色
    self.labelUserName.textColor = [UIColor lightGrayColor];
    
    [self addSubview:self.labelUserName];
    [_labelUserName release];
    
    self.labelStart_date = [[UILabel alloc]init];
    self.labelStart_date.font = [UIFont systemFontOfSize:12 *kWidth];
    
    self.labelStart_date.textColor = [UIColor lightGrayColor];
    self.labelUserName.textAlignment = NSTextAlignmentRight;
    [self addSubview:self.labelStart_date];
    [_labelStart_date release];
    
}

-(void)layoutSubviews
{
    [super layoutSubviews];
    
  
    self.labelDes.frame = CGRectMake(5 * kWidth, 10 *kHeight, self.frame.size.width - 10 *kWidth, [TravelTopicDetailsOneTableViewCell heightOfLabel:self.model.DES andTextFont:[UIFont systemFontOfSize:14 *kWidth] andTextWidth:self.frame.size.width - 10 *kWidth]);
    
    self.labelUserName.frame = CGRectMake(5 *kWidth, 20 *kHeight + self.labelDes.frame.size.height, self.frame.size.width / 2 - 5 *kWidth, 20 *kHeight);
    
    self.labelStart_date.frame = CGRectMake(self.frame.size.width / 2, self.labelUserName.frame.origin.y, self.labelUserName.frame.size.width, 20 *kHeight);
    
    
}

-(void)setModel:(TravelTourMiddleModel *)model
{
    if (_model != model) {
        [_model release];
        _model = [model retain];
    }
    
    self.labelDes.text =model.DES;
    
    self.labelUserName.text =[[model.dicTrip valueForKey:@"user"] valueForKey:@"name"];
    
    self.labelStart_date.text = [model.dicTrip valueForKey:@"start_date"];
    
    
}


-(void)setDic:(NSMutableDictionary *)dic
{
    if (_dic !=dic) {
        [_dic release];
        _dic = [dic retain];
    }
    
    
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
